<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>详情</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body>
        <form id="friBaseInfo_detail_form">
            <div class="fieldset1 tabel_col tabel_col_s clearFix ">
			<div class="fieldBox col_33">
				<div class="label">融资机构名称：</div>
				<div class="field">
					<span name="fundRasInsNm" id="fundRasInsNm" ></span>
				</div>
			</div>
			<div class="fieldBox col_33">
				<div class="label">机构缩写：</div>
				<div class="field">
					<span name="insAbb" id="insAbb" ></span>
				</div>
			</div>
			<div class="fieldBox col_33">
				<div class="label">融资机构类型：</div>
				<div class="field">
					<span name="insTypeCdNm" id="insTypeCdNm" ></span>
				</div>
			</div>
			<div class="fieldBox col_33">
				<div class="label">是否为ABS：</div>
				<div class="field">
					<span name="isAbs" id="isAbs" ></span>
				</div>
			</div>
			<div class="fieldBox col_33">
				<div class="label">机构用途：</div>
				<div class="field">
					<span name="insUseCdNm" id="insUseCdNm" ></span>
				</div>
			</div>
			<div class="fieldBox col_33">
				<div class="label">机构编号：</div>
				<div class="field">
					<span name="insCode" id="insCode" ></span>
				</div>
			</div>
			<div class="fieldBox col_33" id="isOutPayDiv" style="display:none">
				<div class="label">是否外部机构投放：</div>
				<div class="field">
					<span name="isOutPay" id="isOutPay" ></span>
				</div>
			</div>
			<div class="fieldBox col_33" id="insRepayTypeNm"  style="display:none">
				<div class="label">还款方式：</div>
				<div class="field">
					<span name="insRepayTypeNm" id="insRepayType" ></span>
				</div>
			</div>
			<div class="fieldBox col_33"   id="topFinanceDiv"  style="display:none">
				<div class="label">单户累计融资额上限:</div>
				<div class="field">
				<span name="topFinance" id="topFinance" ></span>
				   	万		
				</div>
			</div>
			<div class="fieldBox col_100" id="fileModify">
				<div class="label">资料</div>
				<div class="field">
					<jsp:include page="../../system/sysUlFilesRec/sysUlFileRecListDetail.jsp" flush="true">
						<jsp:param name="pkId" value="${id }" />
						<jsp:param name="tabNm" value="CST_BSC_INFO" />
					</jsp:include>
				</div>
			</div>
			<div class="fieldBox col_100"  id="zgTextDiv" style="display:none">
				<div class="label">资管提示信息：</div>
				<div class="field">
					<span name="zgText" id="zgText" ></span>
				</div>
			</div>
			<div class="fieldBox col_100">
				<div class="label">备注：</div>
				<div class="field">
					<span name="rem" id="rem" ></span>
				</div>
			</div>
			<!-- hide data -->
			<div class="fieldBox col_100" style="display:none;">
				<div class="field">
					<input name="dataId" id="dataId" type="text" class="ui-textbox" value="${id}">
					<input type="hidden" id="tabFlag" value="${tabFlag}"/>
				</div>
			</div>
		</div>

		<table class="sq-formTable">
			<tbody>
				<tr>
					<td style="padding: 0;text-align: center;">
						<table id="tableBank" class="sq-formTable no-border">
							<thead>
								<tr>
									<th class="tbLabel" style="text-align: center;">帐户用途</th>
									<th class="tbLabel" style="text-align: center;">帐户类型</th>
									<th class="tbLabel" style="text-align: center;">开户行号</th>
									<th class="tbLabel" style="text-align: center;">开户行</th>
									<th class="tbLabel" style="text-align: center;">户名</th>
									<th class="tbLabel" style="text-align: center;">帐号</th>
									<th class="tbLabel" style="text-align: center;">帐号备注</th>
									<th class="tbLabel" style="text-align: center;">账户状态</th>
									<c:if test="${tabFlag=='101' }">
									 <th class="tbLabel" style="text-align: center;">审核</th>
									</c:if>
								</tr>
							</thead>
							<tbody>

							</tbody>
						</table>
					</td>
				</tr>
			</tbody>
		</table>
		<br>
		<div class="field" style="display:none" id="ligergrid3">
			资管机构限额信息
		</div>
		<div id="ligergrid2" class="sq-grid" style="display:none"> </div>
		
        </form>
<script type="text/javascript">
    var grid = null;
    $(function () {
        grid = $("#ligergrid2").ligerGrid({
            url: '<%=path%>/rfbase/fundRasInsLim/initList.do?pagesize=100&insId=${id}',
            method: 'get',
            columns: [
                {display: '项目类型', name: 'prjTypCdNm', minWidth: 150},
                {display: '融资额上限（万）', name: 'insLimAmt', minWidth: 150,
                	render: function (rowdata, rowindex, value){
                			if(rowdata.insLimAmt==null ||rowdata.insLimAmt==0 )
                				return "无";
                			else return rowdata.insLimAmt;
                		}
                	},
                {display: '设备数上限（台）', name: 'insLimNum', minWidth: 150,
                	render: function (rowdata, rowindex, value){
        			if(rowdata.insLimNum==null ||rowdata.insLimNum==0 )
        				return "无";
        			else return rowdata.insLimNum;
        		}},
        		{display: '主车数量上限（台）', name: 'mainLimNum', minWidth: 150,
                	render: function (rowdata, rowindex, value){
        			if(rowdata.mainLimNum==null ||rowdata.mainLimNum==0 )
        				return "无";
        			else return rowdata.mainLimNum;
        		}},
        		{display: '挂车数量上限（台）', name: 'handLimNum', minWidth: 150,
                	render: function (rowdata, rowindex, value){
        			if(rowdata.handLimNum==null ||rowdata.handLimNum==0 )
        				return "无";
        			else return rowdata.handLimNum;
        		}},
        		{display: '是否支持纯挂', name: 'isHang', minWidth: 150,
                	render: function (rowdata, rowindex, value){
	        			if(rowdata.isHang == 1){
	        				return "支持";
	        			}else {
	        				return "不支持";
	        			}
        		}}
            ],
            pageSize: 100,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: 200,
            rownumbers:true,
            usePager: false,//是否有分页便签
			isScroll: true,//是否有滚动条
            heightDiff: -2,
            allowUnSelectRow: false,
            alternatingRow: false
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        $("#searchBtn").click(function (event) {
            var form = new liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });


    });

   
</script>
	<script>
		var tabFlag=$('#tabFlag').val();
		$(function() {
		   $("#friBaseInfo_detail_form").ligerForm({
                validate: true
           });
		   addRowBank();
	       initData();
	       initLim();
		});
		
		//父级窗口会调用取消
		frameElement.dialog.onCancel = function () {
			frameElement.dialog.close();
		}
		
		function initData(){
			var dataId = $("#dataId").val();
	    	if(!dataId)return;
	    	var _url = '<%=path%>/rfbase/fribaseinfo/getById.do';
	    	AjaxUtils.ajaxPost(_url, {id:dataId}, callback);
    	}
		
		//新增回调
		function callback(msg){
			if(msg.success == 1){
				 setData(msg.data);//设置数据
			 }else{
				 UIUtils.alertError(msg.info);
			 }
		}
		//设置页面数据
	    function setData(data){
	    	$("#fundRasInsNm").html(data.fundRasInsNm);
	    	$("#insAbb").html(data.insAbb);
	    	$("#insUseCdNm").html(data.insUseCdNm);
	    	$("#insTypeCdNm").html(data.insTypeCdNm);
	    	$("#attCd").html(data.attCd);
	    	$("#rem").html(data.rem);
	    	$("#isAbs").html(renderYesNo(data.isAbs));
	    	$("#crtTm").html(data.crtTm);
	    	$("#zgText").html(data.zgText);
	    	$("#insCode").html(data.insCode);
	    	$("#insRepayType").html(data.insRepayTypeNm);
	    	$("#topFinance").html(data.topFinance);
	    	if(data.isOutPay=='1'){
	    		$("#isOutPay").html('是');
	    	}else{
	    		$("#isOutPay").html('否');
	    	}
	    	if (data.insUseCd.indexOf("2") >=0) {
            	$("#zgTextDiv").attr("style","");
            	$("#ligergrid2").attr("style","");
            	$("#ligergrid3").attr("style","");
            	$("#insRepayTypeNm").attr("style","");
            	$("#topFinanceDiv").attr("style","");
            }else{
            	$("#zgTextDiv").attr("style","display:none");
            	$("#ligergrid2").attr("style","display:none");
            	$("#ligergrid3").attr("style","display:none");
            	$("#insRepayTypeNm").attr("style","display:none");
            	$("#topFinanceDiv").attr("style","display:none");
            }
	    	if (data.insUseCd.indexOf("3") >=0) {
            	$("#isOutPayDiv").attr("style","");
            }else{
            	$("#isOutPayDiv").attr("style","display:none");
            }
	    	var bankVos= data.bankAccInfoVOs;
			for (var i = 0; i < bankVos.length; i++) {
				var bankTr = $('#tableBank tbody tr:eq('+i+')');
				bankTr.find("input[name='id']").val(bankVos[i].id);
				bankTr.find("span[name='accTypCdNm']").html(bankVos[i].accTypCdNm);
				bankTr.find("span[name='pubVerPriCdNm']").html(bankVos[i].pubVerPriCdNm);
				bankTr.find("span[name='banAccNum']").html(bankVos[i].banAccNum);
				bankTr.find("span[name='banAccNm']").html(bankVos[i].banAccNm);
				bankTr.find("span[name='accNm']").html(bankVos[i].accNm);
				bankTr.find("span[name='accNum']").html(bankVos[i].accNum);
				bankTr.find("span[name='rem']").html(bankVos[i].rem);
				//审核状态(REF0037)  0 已保存、1审核中、2审核通过、3审核不通过';alert(bankVos[i].audStsCd);
				var audStsCdNm="";
				var isAud=false;
				if(bankVos[i].audStsCd!=null){
					if(bankVos[i].audStsCd=='0'){
						audStsCdNm="已保存";
						isAud=true;
					}else if(bankVos[i].audStsCd=='1'){
						audStsCdNm="审核中";
					}else if(bankVos[i].audStsCd=='2'){
						audStsCdNm="审核通过";
					}else if(bankVos[i].audStsCd=='3'){
						audStsCdNm="审核不通过";
						isAud=true;
					}
				}//end 审核状态处理
				bankTr.find("span[name='audStsCd']").html(audStsCdNm);
			//  不可发起审核   可以发起审核流程
			    if(tabFlag=='101' && isAud){
			    	bankTr.find("span[name='startFlowAcc']").html('<a href="javascript:startFlowAcc('+bankVos[i].id+')"'+'>审核</a>');
			    }
				
				//审核操作
				/* if(isAud){
				}else{
					bankTr.find("span[name='startFlowAcc']").html("");
				} */
				
				if(i < bankVos.length-1){
					addRowBank();
				}
			}
		};
		
		function addRowBank(){
			$('#tableBank tbody').append('<tr>'+
				'<td style="text-align: center;">'+
					'<div class="field">'+
						'<span name="accTypCdNm" ></span>'+
					'</div>'+
				'</td>'+
				'<td style="text-align: center;">'+
					'<div class="field">'+
						'<span name="pubVerPriCdNm" ></span>'+
					'</div>'+
				'</td>'+
				'<td style="text-align: center;">'+
					'<div class="field">'+
						'<span name="banAccNum" ></span>'+
					'</div>'+
				'</td>'+
				'<td style="text-align: center;">'+
					'<div class="field">'+
						'<span name="banAccNm" ></span>'+
					'</div>'+
				'</td>'+
				'<td style="text-align: center;">'+
					'<div class="field">'+
						'<span name="accNm" ></span>'+
					'</div>'+
				'</td>'+
				'<td style="text-align: center;">'+
					'<div class="field">'+
						'<span name="accNum" ></span>'+
						'<input name="id" type="hidden" class="ui-textbox" value="" >'+
					'</div>'+
				'</td>'+
				'<td style="text-align: center;">'+
					'<div class="field">'+
						'<span name="rem" ></span>'+
					'</div>'+
				'</td>'+
				'<td style="text-align: center;">'+
					'<div class="field">'+
						'<span name="audStsCd" ></span>'+
					'</div>'+
				'</td>'+
				'<td style="text-align: center;">'+
				'<div class="field">'+
					'<span name="startFlowAcc" ></span>'+
				'</div>'+
			'</td>'+
			'</tr>');
		}
		
		//显示是否
		function renderYesNo(value){
			var dateStr = "";
			if(0 == value){
				dateStr = "否";
			}
			if(1 == value){
				dateStr = "是";
			}
			return dateStr;
		}
		//发起融资机构账户审核流程
		function startFlowAcc(_id){
			if(!_id)return;
			var modelTyp ="R019";//流程业务分类-再融资机构账户审核
			if(StringUtils.isEmpty(modelTyp)){
				console.log("modelTyp is null");
				return;
			}
        	var wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting",onClose: function () {}});
			$.ajax({
        		type: 'post',
        		dataType:'json',
        		data:{
        			id:_id
        		},
        		url: '<%=path%>/rfbase/fribaseinfo/addFlowStartForAccount.do',
				success : function(msg) {
					wait_dialog.close();
					alert(msg.info);
					if (msg.success == 1) {
						UIUtils.alertSuccessHold1(msg.info);
						frameElement.dialog.close();
						//grid.reload();
					} else {
						UIUtils.alertErrorHold1(msg.info);
					}
				}
			});
		}
		//机构限额
		function initLim(){
			
		}
	</script>
</body>
</html>